/*
 * Instruction50.java
 *
 * Created on March 21, 2007, 10:28 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package moto9s12sim;

/**
 *
 * @author Fergus Earnshaw
 */
public class Instruction50 extends Instruction {
    
    /** Creates a new instance of Instruction12 */
    public Instruction50()
    {
        this.strAssemblyCode = "NEGB";
        this.bCodes = new byte[1];
        this.bCodes[0] = (byte)Integer.parseInt("50",16);
    }
    
    public boolean excute(M9S12 cpu)
    {
        cpu.PC.inc();
        this.shAddr = cpu.PC.getRegister();
        
        cpu.B.setRegister((byte)~cpu.B.getRegister());
        cpu.B.inc();
        //set flags
        cpu.CC.setN(cpu.B.getRegister() < 0);
        cpu.CC.setZ(cpu.B.getUnsignedRegister() == 0);
        cpu.CC.setV(cpu.B.getHex() == "80");
        cpu.CC.setC(cpu.B.getHex() != "00");
        
        printInstruction(cpu);
        return true;
    }  
    
}
